package com.ionehe.rest;

import com.ionehe.component.ProducerClient;
import com.ionehe.enums.MessageType;
import com.ionehe.model.api.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
public class TestController {

    @Autowired
    private ProducerClient producerClient;

    @RequestMapping("/test1")
    public String test1() throws Exception {
        for (int i = 0; i < 1; i++) {
            String uniqueId = UUID.randomUUID().toString();
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("name", "陈秀");
            attributes.put("age", "18");
            Message message = new Message(
                    uniqueId,
                    "exchange1",
                    "springboot.abc",
                    attributes,
                    0, MessageType.RELIANT);
            producerClient.send(message);
        }

        Thread.sleep(100000);

        return "success";
    }
}